import xlsxwriter

# 创建Excel
wb = xlsxwriter.Workbook("data.xlsx")
css_fromat = wb.add_format({"bold":True})  # 格式对象
# 创建sheet
css2 = wb.add_format()
css2.set_bold()
css2.set_font_color("red")
css2.set_font_size(14)
css2.set_align("center")

css3 = wb.add_format()
css3.set_bg_color("#808080")
sheet = wb.add_worksheet("newsheet")

sheet.write(0, 0, "2020年度", css_fromat)
sheet.merge_range(1,0,2,2,"第一季度销售统计", css2)
data = (
    ["一月份",500, 450],
    ["二月份",600, 450],
    ["三月份",700, 550],
)

sheet.write_row(3, 0, ["月份", "预期销售额", "实际销售额"], css3)
# 写入数据
for  index, item in enumerate(data):
    sheet.write_row(index+4, 0, item)

sheet.write(7, 1, "=sum(B5:B7)")
sheet.write(7, 2, "=sum(C5:C7)")
sheet.write_url(9, 0, "http://wwww.baidu.com", string="more data")
sheet.insert_image(10, 0, "excelimage.png")

wb.close()